using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.Web;
using System.ComponentModel;
using System.Drawing;
using Org.Eurekaa.DNJ.Helpers;


namespace Org.Eurekaa.DNJ.WebControls
{
    [ToolboxBitmap(typeof(Panel))]
    [Designer(typeof(Org.Eurekaa.DNJ.Design.WebControls.DNJPanelDesigner))]
    public class DNJPanel : Panel
    {
        private string _DNJClassName = ConstNames.DNJ_DefaultCssClass;

        public string DNJClassName
        {
            get { return _DNJClassName; }
            set { _DNJClassName = value; }
        }

        protected override object SaveViewState()
        {
            PageHelper.RegisterDNJResource("dnj", this.Page.Header); 
            return base.SaveViewState();
        }
        public override void RenderBeginTag(System.Web.UI.HtmlTextWriter writer)
        {
            if (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Form[ConstNames.DNJ_DefaultCssClass] != null)
                writer.Write(ConstNames.DNJ_OpenTag);

            base.RenderBeginTag(writer);
        }
        public override void RenderEndTag(System.Web.UI.HtmlTextWriter writer)
        {
            base.RenderEndTag(writer);

            if (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Form[ConstNames.DNJ_DefaultCssClass] != null)
                writer.Write(ConstNames.DNJ_CloseTag);
        }
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            this.CssClass = _DNJClassName + " " + this.CssClass;            
            base.Render(writer);
        }
    }
}
